//
// Created by lzd on 2021/9/8.
//
//利用Horner法则的多项式计算
#include <iostream>
using namespace std;

template <class T>
void rank(T a[], int n, int r[]) {
    for (int i = 0; i < n; i++) {
        r[i] = 0;
    }
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < i; j++) {
            if (a[j] <= a[i]) r[i]++;
            else r[j]++;
        }
    }

}

int main() {
    int a[] = {4, 3, 9, 3, 7};
    int b[5];
    rank(a, 5, b);
    for (auto &c : b) {
        cout << c <<" ";
    }
    return 0;
}